var mySwiper = new Swiper('.swiper', {
    autoplay:true,//等同于以下设置
    loop : true,
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
      },
      pagination: {
        el: '.swiper-pagination',
        clickable :true,
      },
  });

 let kindLi= document.querySelectorAll('#kindList li')
 let businessList= document.querySelectorAll('.business-center .business-left')
let businessCenter= document.querySelector(".business-center")

let returnTop= document.querySelector('.return-top')

 kindLi.forEach(function(dom,i){
  dom.addEventListener('mouseover',function(){
    this.style.backgroundColor='#1271ef'
    this.style.color='#fff'
    this.querySelector('img').src=`../imgs/api0${i+1}-c.svg`

    // this.childeren[0].children[0]
    // this.firstElementChild.firstElementChild
    // this.querySelector('img')
  })
  dom.addEventListener('mouseout',function(){
    this.style.backgroundColor='#fff'
    this.style.color='black'
    this.querySelector('img').src=`../imgs/api0${i+1}.svg`
  })
 })

 let index=0
 let timeId= setInterval(RunTime,2000)

 businessCenter.addEventListener('mouseover',function(){
    clearInterval(timeId)
 })
 businessCenter.addEventListener('mouseout',function(){
  timeId= setInterval(RunTime,2000)
})

function RunTime(){
    businessList[index].classList.remove('active')
  
    index++
    if(index===businessList.length) index=0
    
    businessList[index].classList.add('active')
}

returnTop.addEventListener('mouseover',function(){
  returnTop.style.backgroundPositionY='-96px'
})
returnTop.addEventListener('mouseout',function(){
  returnTop.style.backgroundPositionY='-54px'
})

window.addEventListener('scroll',function(){
  let rTop= document.documentElement.scrollTop
  console.log(rTop);
  if(rTop>=800){
    returnTop.style.display='block'
  }else{
    returnTop.style.display='none'
  }
})

returnTop.addEventListener('click',function(){
  // window.scrollTo({
  //   top:0,
  //   behavior:"smooth"
  // })
  buffer(document.documentElement, {scrollTop:0})
})

// pheadLi()